package com.mtf.transation.service.impl;

import com.mtf.entity.MtfOrder;
import com.mtf.service.IMtfOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author matengfei
 * @Date 2024/6/29 11:29
 * @PackageName:com.mtf.transation.service.impl
 * @ClassName: ExampleServiceImpl
 * @Description: TODO
 * @Version 1.0
 */
@Service
public class ExampleServiceImpl {
    @Autowired
    private IMtfOrderService orderService;
    @Autowired
    private PropagationServiceImpl propagationService;

    @Transactional
    public void saveOrder1(MtfOrder order) {
        orderService.save(order);
        propagationService.required();
    }

    @Transactional
    public void saveOrder2(MtfOrder order) {
        orderService.save(order);
        try {
            propagationService.required();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Transactional
    public void saveOrder3(MtfOrder order) {
        orderService.save(order);
        try {
            propagationService.requiresNew();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Transactional
    public void saveOrder4(MtfOrder order) {
        orderService.save(order);
        propagationService.requiresNew();
    }
}
